{% extends "tj3/tj3.html" %}

{% block navigation %}
	<script type="text/javascript">
		$('document').ready(function(){
			$('#create_btn').button();
			$('#cancel_btn').button();
		});
	</script>

{% endblock navigation %}

{% block content  %} 

<h1 class="ui-widget ui-widget-header">{{task.project.name}}/{{task.name}} <span class="float_right">Create a New Budget</span></h1>

<div class="ui-widget ui-widget-content">	
	<!--- new budget --->

	{% if duplicate_scenario %}
	<div class="ui-state-error mycontent fancy ui-corner-all">
	<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
	Budget for scenario "{{duplicate_scenario.name|capfirst}}" already exists! One scenario can have only one budget defined!</div>
	{% endif %}
	
	<div class="mycontent">
	<form action="." method="post" enctype="multipart/form-data">
	{{ budget_formset.management_form}}
		<div>
		{% for b in budget_formset.forms %}
		<table>
			<tr><td>Scenario:<td>{{b.scenario}}
			<tr><td>Budget:<td>{{b.budget}}
			<tr><td>Management Reserve:<td>{{b.reserve}}
		</table>
		{% endfor %}
		</div>
		
		<div class="float_right">
			<input id="create_btn" type="submit" name="command" value="Create" class="button" />
			<input id="cancel_btn" type="submit" name="command" value="Cancel" class="button" />
		</div>
	</form>
	</div>
	
	<div class="mycontent">
	<h2 class="ui-state-highlight">Existing Budgets</h2>
	<table>
		<tr><td>{% for b in budgets %}<td>
			<a href={%url budget_edit b.id %}>
				{{b.scenario|capfirst}}
				<span class="ui-icon ui-icon-wrench"></span>
			</a>
			{%endfor%}
		<tr><td>Budget:{% for b in budgets %}<td>{{b.budget}}{%endfor%}
		<tr><td>Management Reserve:{%for b in budgets%}<td>{{b.reserve}}{%endfor%}
	</table>
	</div>
	
</div>


{% endblock content %}
